﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Entity.Table;
using SqlHelper;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
    public class DetailFileExceptionDatabase
    {
        /// <summary>
        /// 添加一条明细对帐和总帐金额不符的异常信息
        /// </summary>
        /// <param name="dfException">实体对象</param>
        /// <returns></returns>
        public static bool Insert(TB_DetailFileException dfException)
        {
            bool ret = true;
            SqlConnection conn = null;

            SqlParameter[] paramList = new SqlParameter[] { DbHelper.CreateCommandParameter("@BankCode",SqlDbType.VarChar,dfException.BankCode),
                                                            DbHelper.CreateCommandParameter("@BusinessDate",SqlDbType.VarChar,dfException.BusinessDate),
                                                            DbHelper.CreateCommandParameter("@TotalZJE",SqlDbType.Decimal,dfException.TotalAccountMoney),
                                                            DbHelper.CreateCommandParameter("@DetailZJE",SqlDbType.Decimal,dfException.DetailAccountMoney),
                                                            DbHelper.CreateCommandParameter("@FileName",SqlDbType.VarChar,dfException.FileName),
                                                            DbHelper.CreateCommandParameter("@ExceptionInfo",SqlDbType.NVarChar,dfException.ErrorMsg),
                                                            DbHelper.CreateCommandOutParameter("@return",SqlDbType.Int)
                                                           };
            try
            {
                conn = DbHelper.CreateDbConnection(DbHelper.DbConnectionString);
                conn.Open();
                ret = DbHelper.ExecuteNonQueryByProc("NXS_DetailFileException_Insert", paramList, conn) > 0;
            }
            catch (SqlException ex)
            {
                ret = false;
            }
            finally
            {
                conn.Close();
            }
            return ret;
        }
    }
}
